package com.ship.dispatch.util;

import java.util.List;
import java.util.Map;

public class SpYearlyPlanProvider {
    public String getYearlyPlanByColumnKeys(Map<String, Object> params) {
        List<String> columnKeys = (List<String>) params.get("columnKeys");

        // 构建查询字段
        StringBuilder query = new StringBuilder("SELECT id ");
        for (String columnKey : columnKeys) {
            String transformedColumnKey = columnKey.replaceAll("([A-Z])", "_$1").toLowerCase();
            query.append(", ").append(transformedColumnKey);
        }

        query.append(" FROM sp_yearly_plan");

        return query.toString();
    }

    public String getYearlyPlanSchemeByColumnKeys(Map<String, Object> params) {
        List<String> columnKeys = (List<String>) params.get("columnKeys");

        // 构建查询字段
        StringBuilder query = new StringBuilder("SELECT id ,last_detail_id,single_goods_quantity");
        for (String columnKey : columnKeys) {
            String transformedColumnKey = columnKey.replaceAll("([A-Z])", "_$1").toLowerCase();
            query.append(", ").append(transformedColumnKey);
        }

        query.append(" FROM sp_year_plan_scheme_detail");

        return query.toString();
    }

    public String getDispatchSchemeByColumnKeys(Map<String, Object> params) {
        List<String> columnKeys = (List<String>) params.get("columnKeys");

        // 构建查询字段
        StringBuilder query = new StringBuilder("SELECT id ");
        for (String columnKey : columnKeys) {
            String transformedColumnKey = columnKey.replaceAll("([A-Z])", "_$1").toLowerCase();
            query.append(", ").append(transformedColumnKey);
        }

        query.append(" FROM sp_dispatch_scheme_detail");

        return query.toString();
    }

}
